/*
 * Copyright 2008 Georgi Staykov
 * 
 * This file is part of pscoder.
 *
 * pscoder is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * pscoder is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with pscoder.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.gstaykov.pscoder;

import org.eclipse.core.runtime.Preferences;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

import com.gstaykov.pscoder.preferences.PreferenceConstants;

/**
 * The activator class controls the plug-in life cycle
 */
public class Activator extends AbstractUIPlugin {

	// The plug-in ID
	public static final String PLUGIN_ID = "com.gstaykov.pscoder";

	// The shared instance
	private static Activator plugin;
	
	/**
	 * The constructor
	 */
	public Activator() {
	}

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext context) throws Exception {
		super.start(context);
		plugin = this;
	}

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext context) throws Exception {
		plugin = null;
		super.stop(context);
	}

	@Override
	protected void initializeDefaultPluginPreferences() {
	    Preferences preferences = plugin.getPluginPreferences();
	    preferences.setDefault(PreferenceConstants.INCLUDE_CUSTOMCMDLETS, true);
	    preferences.setDefault(PreferenceConstants.INCLUDE_PSCMDLETS, true);
	    preferences.setDefault(PreferenceConstants.PS_SNAPIN_FILES, "");
	    preferences.setDefault(PreferenceConstants.TAB_WIDTH, 4);
	    preferences.setDefault(PreferenceConstants.COLOR_COMMENT, "0,128,0");
        preferences.setDefault(PreferenceConstants.COLOR_STRING, "0,128,255");
        preferences.setDefault(PreferenceConstants.COLOR_VARIABLE, "200,50,50");
        preferences.setDefault(PreferenceConstants.COLOR_KEYWORD, "128,0,64");
        preferences.setDefault(PreferenceConstants.COLOR_DASH_KEYWORD, "255,0,64");
        preferences.setDefault(PreferenceConstants.COLOR_OTHER, "0,0,0");
	}
	
	/**
	 * Returns the shared instance
	 *
	 * @return the shared instance
	 */
	public static Activator getDefault() {
		return plugin;
	}

}
